<template>
    <div id="cutEight">
        <v-nav></v-nav>
        <div class="newAdd">
            <img class="poster" src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/change/cuteight_background.jpg">
        </div>
        <div class="newProductListWrapper" style="background:#def7f3;overflow: hidden;">
            <section style="margin-top: 0;overflow: hidden;">
                <div class="newProductList flo-l" v-for="(x,y) in list" >
                    <div class="classify"><span>{{x.title}}</span></div>
                    <div class="list" v-for="z in x.proList" :id="z.pro_id" :type="z.id_type" @click="goNewDetail(z.pro_id,z.id_type)">
                        <header>
                            <dl>
                                <dd><img :src="z.pro_img"></dd>
                                <img v-if="z.stock_num===1" src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/imgChange/WechatIMG146.png" style="position:absolute;top: 22%;left:14%;width: 1.8rem;height:1.8rem;">
                                <dt style="text-align: left">{{z.subtitle}}</dt>
                            </dl>
                        </header>
                        <footer>
                            <div>
                                <span class="priceColor flo-l">￥</span>
                                <span class="flo-l"><del class="priceColor">{{z.pro_price}}</del></span>
                                <span class="flo-r">砍到{{z.min_shop_price}}元</span>
                            </div>
                        </footer>
                    </div>
                </div>
            </section>
        </div>
    </div>
</template>

<script>
  import store from "../store/newStore.js";
  import config from "../config/config.js";
  import share from "../share/share.js";
  import Nav from "../home/nav.vue";
  import MtaH5 from 'mta-h5-analysis';
  export default {
    name: "cut-zero",
    store,
    data() {
      return {
        list: [],
        pageSize:1,
      }
    },
    computed:{
      ticket(){
        return this.$store.state.getTicket;
      }
    },
    components:{
      "v-nav":Nav
    },
    methods: {
      getViewInfo(pageSize) {
        var tag = this.$route.params.tag;
        var value = JSON.stringify({
            "page": pageSize,
            "tag": tag,
            "token": localStorage.getItem('token')
          }),
          key = demo(value);
        axios.post('/Home/home/HomeTopButton', {
          value: value,
          key: key,
          ticket:this.ticket
        }, config)
          .then(function (response) {
            if (response.data.code == 200) {
              if(pageSize==1){
                this.list=response.data.data.list;
              }else{
                this.list=this.list.concat(response.data.data.list);
              }
              if(response.data.data.listNum==pageSize){
                this.$nextTick(function(){
                  this.allLoaded=true;
                })
              }else{
                this.$nextTick(function(){
                  this.allLoaded=false;
                })

              }
              this.$store.commit('increment',response.data.ticket);
            }else{
              this.$store.commit('increment',response.data.ticket);
            }
          }.bind(this))
          .catch(function (error) {
            console.log(error);
          });
      },
      loadBottom(){
        var self = this;
        setTimeout(function () {
          self.pageSize++;
          self.getViewInfo(self.pageSize);
          self.$refs.loadmore.onBottomLoaded();
        }, 500);
      },
      goNewDetail(id,type){
        this.$router.push('/newDetail/'+id+'/'+type)
      },
    },

    activated() {
      share({})
      this.getViewInfo(this.pageSize);
      MtaH5.init({
        "sid":'500594815',
        "cid":'500595819',
        "autoReport":0,
        "senseHash":0,
        "senseQuery":0,
        "performanceMonitor":0,
        "ignoreParams":[]
      });
      MtaH5.pgv();
    },
    deactivated(){
      this.$destroy(true)
    }
  }
</script>

<style scoped>

</style>